<%@page import="com.dfhc.util.StringHelper"%>
<%@ page import="org.quickbundle.orgauth.rmauthorize.util.IRmAuthorizeConstants" %>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />

<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title> </title>

<%@ taglib uri="/dfhc" prefix="dfhc" %>
</head>
<body>


<article class="page-container">


	<form action="" method="post" class="form form-horizontal" id="form-add">
	   <input type="hidden" id="id" name="id" value="${bean.id}">
							
		<dfhc:div templateId="h_ui_div_row_cl">
	   <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("name")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	        
			<dfhc:input templateId="h_ui_input" class="input-text"  value="${bean.name}"  id="name"  placeholder=""  name="name" />	
	    </dfhc:div>
	    <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("bs_keyword")%>：</dfhc:label>	    
	    <dfhc:div templateId="h_ui_div_label_div" >	         
			<dfhc:input templateId="h_ui_input" class="input-text"  value="${bean.bs_keyword}"  id="bs_keyword"  placeholder=""  name="bs_keyword" />			
	 	</dfhc:div>
	  </dfhc:div>
	  
	  <dfhc:div templateId="h_ui_div_row_cl">
	   <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("is_alone_table")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	 
			<dfhc:select templateId="h_ui_select" size="1" name="is_alone_table" id="is_alone_table" pleaseSelect="1" defaultValue="${bean.is_alone_table}" sqlOption="code" code="<%=IRmAuthorizeConstants.DICTIONARY_RM_YES_NOT%>" />					
	    </dfhc:div>
	    <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("authorize_resource_table_name")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	        
			<dfhc:input templateId="h_ui_input" class="input-text"  value="${bean.authorize_resource_table_name}"  id="authorize_resource_table_name"  placeholder=""  name="authorize_resource_table_name" />
	    </dfhc:div>
	  </dfhc:div>
	  
	  <dfhc:div templateId="h_ui_div_row_cl">
	   <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("authorize_resrec_table_name")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	        
			<dfhc:input  templateId="h_ui_input" type="text"   name="authorize_resrec_table_name" id="authorize_resrec_table_name" value="${bean.authorize_resrec_table_name}" />	
	    </dfhc:div>
	    <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("authorize_affix_table_name")%>：</dfhc:label>	    
	    <dfhc:div templateId="h_ui_div_label_div" >	         
			<dfhc:input  templateId="h_ui_input" value="${bean.authorize_affix_table_name}" id="authorize_affix_table_name"  name="authorize_affix_table_name"   />
	 	</dfhc:div>
	  </dfhc:div>
	  
	  <dfhc:div templateId="h_ui_div_row_cl">
	   <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("settiing_option")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	        
			<dfhc:select templateId="h_ui_select" size="1" name="settiing_option" id="settiing_option" pleaseSelect="1" defaultValue="${bean.settiing_option}" sqlOption="code" code="<%=IRmAuthorizeConstants.DICTIONARY_RM_OPTION_TYPE%>" />		
	    </dfhc:div>
	    <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("custom_code")%>：</dfhc:label>	    
	    <dfhc:div templateId="h_ui_div_label_div" >	         
			<dfhc:input  templateId="h_ui_input" value="${bean.description}" id="custom_code"  name="custom_code"   />
	 	</dfhc:div>
	  </dfhc:div>
	  
	  <dfhc:div templateId="h_ui_div_row_cl">
	   <dfhc:label	 templateId="h_ui_div_label_row_cl"><%=IRmAuthorizeConstants.TABLE_COLUMN_CHINESE.get("description")%>：</dfhc:label> 	    
	    <dfhc:div templateId="h_ui_div_label_div" >	        
			<dfhc:input  templateId="h_ui_input" type="text"   name="description" id="description" value="${bean.description}" />	
	    </dfhc:div>
	  </dfhc:div>
	  
	  
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:div templateId="h_ui_div_pop_up_button">
				<dfhc:button templateId="h_ui_submit_button" />
				<dfhc:button templateId="h_ui_cancel_button" onclick="cancel();" />
				<dfhc:button templateId="h_ui_reset_button" onclick="reset();" />
			</dfhc:div>
		</dfhc:div>
	</form>
</article>



<script type="text/javascript">
var _table;
var newusrl=getRootPath()+"/rmAuthorize";
$(function(){
	<c:if test="${not empty bean}"> 
	</c:if>
	
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	
	
	$("#form-add").validate({
		rules:{
			name:{			
			},
			bs_keyword:{			
			},
			is_alone_table:{			
			},
			authorize_resource_table_name:{			
			},
			authorize_resrec_table_name:{			
			},
			authorize_affix_table_name:{			
			},
			settiing_option:{			
			},
			custom_code:{			
			},
			description:{			
			}
		},
 		messages: {
 			name:{			
			},
			bs_keyword:{			
			},
			is_alone_table:{			
			},
			authorize_resource_table_name:{			
			},
			authorize_resrec_table_name:{			
			},
			authorize_affix_table_name:{			
			},
			settiing_option:{			
			},
			custom_code:{			
			},
			description:{			
			}
	    },		
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			<c:if test="${empty bean}"> 
			var url = getRootPath()+"/rmAuthorize/insert?jsguid="+$('#id').val();
			</c:if>
			<c:if test="${not empty bean}"> 
			var url = getRootPath()+"/rmAuthorize/update?jsguid="+$('#id').val();
			</c:if>
			//提交成功关闭
			submitAjax(url,$("#form-add").serialize(),newusrl);
			/* window.location.href=newusrl; */
		}
	});
});
function submitAjax(url,param,successUrl){
 	//url后面自动带jsguid
	if(url.indexOf("jsguid")==-1){
		 if(url.indexOf("?")==-1){
			   url = url+"?jsguid="+__global_guid;
		 }else{
			   url = url+"&jsguid="+__global_guid;
		 }
	}
	//url 后面自动带csrf 编码
	if(!isStrEmpty($('#_csrfcode_').val())){
		if (url.indexOf("?") == -1) {
			url = url + "?_csrfcode_=" + $('#_csrfcode_').val();
		} else {
			url = url + "&_csrfcode_=" + $('#_csrfcode_').val();
		}
	}
 
	 $.ajax({
	    type:'post',//可选get
	    url:url,
	    data:param,//送评表的表格id属性值
	    dataType:'json',
	    async:false , //false为同步
	    success:function(data,status){
	      //更新csrf随机码
	      $("#_csrfcode_").val(data._csrfcode_);
		  if(data.status=="0"){
		  	  layer.msg(data.message,{icon:1,time:1000});
			  //alert(data.message);
			  return false;
	   	   }else{	   	      
	   		  alert(data.message);
	   		  layer.msg(data.message,{icon:1,time:1000});
	   		  if(!isStrEmpty(successUrl)){
	   		    window.location.href=successUrl;
	   		  }	   		  
	   		  return true;   		
	   	   }
		   	
	   },
	   error:function(xhr,s1,s2){
			var  message= xhr.responseText;
	    	var  json = jQuery.parseJSON(message);
	
			if($.trim(json.exception).length==0){
				alert('数据异常,请刷新页面重试');
			}else{
				alert(json.exception);
			}
			return false;			
	   }
	   });
}
function singleDelete(url){
	//判断是否选择
	var len = $('input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('input[name="allId"]:checked').each(function(){     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+=dataId
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择删除的记录!");
       return;
    }  
    
    if(count>1){
       alert("只能选择一条记录!");
       return;	
    }
    var newUrl ;
    if(url.indexOf("?")>=0){
    	newUrl = url+'&id='+ids+'&jsguid='+ids;
    }else{
    	newUrl = url+'?id='+ids+'&jsguid='+ids;
    }
    //url 后面自动带csrf 编码
	if(!isStrEmpty($('#_csrfcode_').val())){
		if (newUrl.indexOf("?") == -1) {
			newUrl = newUrl + "?_csrfcode_=" + $('#_csrfcode_').val();
		} else {
			newUrl = newUrl + "&_csrfcode_=" + $('#_csrfcode_').val();
		}
	}
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: newUrl,
			dataType: 'json',
			success: function(data){
				//$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
				$('.table-sort').DataTable().ajax.reload();
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
	$('.table-sort').DataTable().ajax.reload();
}
function cancel(){
	window.location.href=getRootPath()+"/rmAuthorize";
}
function reset(){
	$("#name").val('');
	$("#bs_keyword").val('');
	$("#is_alone_table").val('');
	$("#authorize_resource_table_name").val('');
	$("#authorize_resrec_table_name").val('');
	$("#authorize_affix_table_name").val('');
	$("#settiing_option").val('');
	$("#custom_code").val('');
	$("#description").val('');
}
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
